﻿#ifndef XRTCSDK_XRTC_XRTC_H_
#define XRTCSDK_XRTC_XRTC_H_
#include <string>
#include <memory>

namespace xrtc {

class MediaFrame;
class XRTCPusher;

enum class XRTCError {
    kNoErr = 0,
    kVideoCreateCaptureErr = -1000,
    kVideoNoCapabilitiesErr,
    kVideoNoBestCapabilitiesErr,
    kVideoStartCaptureErr,
    kPreviewNoVideoSourceErr,
    kChainConnectErr,
    kChainStartErr,
    kPushNoVideoSourceErr,
    kPushInvalidUrlErr,
    kPushRequestOfferErr,
    kPushIceConnectionErr,
};

class IXRTCConsumer {
public:
    virtual ~IXRTCConsumer() {}
    virtual void OnFrame(std::shared_ptr<MediaFrame> frame) = 0;
};

class IMediaSource {
public:
    virtual ~IMediaSource() {}

    virtual void Start() = 0;
    virtual void Setup(const std::string& json_config) = 0;
    virtual void Stop() = 0;
    virtual void Destroy() = 0;
    virtual void AddConsumer(IXRTCConsumer* consumer) = 0;
    virtual void RemoveConsumer(IXRTCConsumer* consumer) = 0;
};

class IVideoSource : public IMediaSource {

};

class  XRTCEngineObserver {
public:
 
    virtual void OnPushSuccess(XRTCPusher*) {}
    virtual void OnPushFailed(XRTCPusher*, XRTCError) {}
    virtual void OnNetworkInfo(int64_t rtt_ms, int32_t packets_lost,
        uint8_t fraction_lost, uint32_t jitter) {}
};

class  XRTCEngine {
public:
    static void Init(XRTCEngineObserver* observer);
    static XRTCPusher* CreatePusher(IVideoSource* video_source);
};

} // namespace xrtc

#endif // XRTCSDK_XRTC_XRTC_H_